package guiPackage;

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import systemPackage.LocalStrings;
import systemPackage.MainSystem;

import dataTypesPackage.Musteri;

public class GUI_NewMusteri extends JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2314490366392313689L;
	private JLabel nameLabel = new JLabel(LocalStrings.getLocalString(1));
	private JTextField nameField = new JTextField();
	private JLabel surNameLabel = new JLabel(LocalStrings.getLocalString(2));
	private JTextField surNameField = new JTextField();
	private JButton saveButton = new JButton(LocalStrings.getLocalString(3));
	
	
	public GUI_NewMusteri(){
		createWindow();
	}
	
	public void createWindow(){
		this.setDefaultCloseOperation ( JFrame.DISPOSE_ON_CLOSE );
		Container container = getContentPane();
		container.setLayout(new GridLayout(3,2));
		container.add(nameLabel);
		container.add(nameField);
		container.add(surNameLabel);
		container.add(surNameField);
		ActionListener saveButtonPress = new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// This method calls for mainSystem to add new client.
				Musteri newMusteri = new Musteri(nameField.getText(), surNameField.getText());
				MainSystem.set(newMusteri, Musteri.class);
				dispose();
			}
		};
		saveButton.addActionListener(saveButtonPress);
		container.add(saveButton);
		this.setSize(240, 100);
	}
	
}
